<?php
	class Help extends MY_controller{

		function __construct(){
			parent::__construct();
		}

		public function index($cid = 0, $limit = 0){
			$this->load->model("Helps");
			$news_cate_list = array();
			// $news_cate_list = $this->Helps->get_category();
			$conditions['school_id'] = $this->school_id;
			$conditions['cid'] = $cid;
			$help_list = $this->Helps->get_help_list($limit, $offset = 10, $conditions);
			$this->load->library('pagination');
			$page_config['base_url'] = '/help/index';
			$page_config['total_rows'] = $help_list['count'];
			$page_config['per_page'] = $offset;
			$page_config['uri_segment'] = 4;
			$this->pagination->initialize($page_config);
			$pagination = $this->pagination->create_links();
			// $new_list = $this->Helps->get_news10($this->school_id);
			$this->load->model("Questions");
			$conditions = array('category_id' => 0, "school_id" => $this->school_id, "type" => 2);
			$hot_question = $this->Questions->get_question_list($limit, $offset, $conditions);
			$new_list = $this->Newses->get_news10($this->school_id);
			$this->smarty->assign("new_list", $new_list);
			$this->smarty->assign("hot_question", $hot_question['result']);
			$this->smarty->assign("cid", $cid);
			$this->smarty->assign("news_list", $help_list['result']);
			$this->smarty->assign("pagination", $pagination);
			$this->smarty->display("help/list.html");
		}

		function detail($id = 0){
			$this->load->model("Helps");
			$news_info = get_field_by_where("o2o_school_helps", "*", "id='{$id}'");

			$prev_news = get_field_by_where("o2o_school_helps", "id, title", "id > '{$id}' AND school_id = '{$this->school_id}'");
			$next_news = get_field_by_where("o2o_school_helps", "id, title", "id < '{$id}' AND school_id = '{$this->school_id}'");
			$this->load->model("Questions");
			$conditions = array('category_id' => 0, "school_id" => $this->school_id, "type" => 2);
			$hot_question = $this->Questions->get_question_list(0, $offset = 10, $conditions);
			$this->load->model("Newses");
			$new_list = $this->Newses->get_news10($this->school_id);
			$this->smarty->assign("new_list", $new_list);
			$this->smarty->assign("hot_question", $hot_question['result']);
			$this->smarty->assign("prev_news", $prev_news);
			$this->smarty->assign("next_news", $next_news);
			$this->smarty->assign("news_info", $news_info);
			$this->smarty->display("help/detail.html");
		}
	}